package com.bschlearn.group.common.task;

import java.util.concurrent.Future;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

/**
 * 
 * @ClassName: AsyncTask 
 * @Description: TODO(异步线程对象，使用@Async注解表明这是一个异步线程) 
 * @author dcc
 * @date 2019年6月20日 上午9:57:44 
 *
 */
@Component
public class AsyncTask {
	
	@Async
	public Future<Boolean> doTask11() throws Exception{
		long start = System.currentTimeMillis();
		Thread.sleep(1000);
		long end = System.currentTimeMillis();
		System.out.println("任务1耗时："+(end-start)+"毫秒");
		return new AsyncResult<>(true);
	}
	
	@Async
	public Future<Boolean> doTask22() throws Exception{
		long start = System.currentTimeMillis();
		Thread.sleep(1000);
		long end = System.currentTimeMillis();
		System.out.println("任务2耗时："+(end-start)+"毫秒");
		return new AsyncResult<>(true);
	}
	
	@Async
	public Future<Boolean> doTask33() throws Exception{
		long start = System.currentTimeMillis();
		Thread.sleep(1000);
		long end = System.currentTimeMillis();
		System.out.println("任务3耗时："+(end-start)+"毫秒");
		return new AsyncResult<>(true);
	}

}
